|
Data Services Developer's Guide : Declare a Security Resource
This page last changed on Jan 09, 2008 by tkatz.
eDocs Home > BEA AquaLogic Data Services Platform 3.0 Documentation > Data Services Developer's Guide
|
| You can follow these steps on a physical or logical entity service. Be sure the service has a query map and a primary read function. |
To create a security resource:
Window > Show View > Properties
(::pragma xds <x:xds targetType="cus:CustomerOrder" xmlns:x="urn:annotations.ld.bea.com" xmlns:cus="ld:logical/CustomerOrder"> <creationDate>2007-10-22T13:36:48</creationDate> <userDefinedView/> <key name="DefaultKey" inferred="true" inferredSchema="true" type="cus:CustomersAndOrders_KEY"> <selector xpath="CUSTOMER"/> </key> <secureResources> <secureResource>CUSTOMER</secureResource> </secureResources> </x:xds>::-)
The next step is to add a condition to the return type so that it is returned only if the caller has access. To do this, make changes visually in the Query Map. You want to add a conditional statement to the service's primary read function, something like this:
declare function tns:read() as element(cus:CustomerOrder)*{
for $CUSTOMER in cus1:CUSTOMER()
return
<cus:CustomerOrder>
{
if (add-authentication-expression-here) then
<CUSTOMER>
return type here ..
</CUSTOMER>
else
<CUSTOMER>{return nothing here}</CUSTOMER>
}
</cus:CustomerOrder>
To add the conditional statement, you need to:
The following example shows how to create a security resource on an element in the return type, using the primary read function.
XQuery Functions > Data Services Access Control Functions
fn-bea:is-access-allowed($label, $data_service)
fn-bea:is-access-allowed("CUSTOMER", "ld:logical/CustomersAndOrders.ds")
declare function tns:read() as element(cus:CustomerOrder)*{
for $CUSTOMER in cus1:CUSTOMER()
return
<cus:CustomerOrder>
{
if (fn-bea:is-access-allowed("CUSTOMER", "ld:logical/CustomersAndOrders.ds")) then
<CUSTOMER>
...
</CUSTOMER>
else
<CUSTOMER>
...
</CUSTOMER>
}
declare function tns:read() as element(cus:CustomerOrder)*{
for $CUSTOMER in cus1:CUSTOMER()
return
<cus:CustomerOrder>
{
if (fn-bea:is-access-allowed("CUSTOMER", "ld:logical/CustomersAndOrders.ds")) then
<CUSTOMER>
<CUSTOMER_ID>{fn:data($CUSTOMER/CUSTOMER_ID)}</CUSTOMER_ID>
<FIRST_NAME>{fn:data($CUSTOMER/FIRST_NAME)}</FIRST_NAME>
<LAST_NAME>{fn:data($CUSTOMER/LAST_NAME)}</LAST_NAME>
<SSN?>{fn:data($CUSTOMER/SSN)}</SSN>
...
</CUSTOMER>
else
<CUSTOMER>{"NA"}</CUSTOMER>
}
</cus:CustomerOrder>
}
The next step is to use the ALDSP console to create a security policy.
| Securing AquaLogic Data Services Platform Resources |
All you need to do in the ALDSP console is create a security policy. You have already created a custom security resource and added it to an XQuery function or procedure.
Once you establish security resources, you should test security in Test view.
To test a security resource:
Check that the function returns either valid results if the authentication credential passes the security policy, or the string NA if it is not.
![]()
Contact BEA | Feedback | Privacy | (c) 2008 BEA Systems
| Document generated by Confluence on Jan 15, 2008 11:02 |